<?php
namespace app\user\validate;

use Utils\PasswordHash;

class PasswordValidate {
    public const needUpgrade = ['md5_salt'];
    public const defaultMethod = 'phpass';

    public static function compareMd5Salt($hash, $input){
        list($salt, $md5) = explode(',', $hash);
        return md5(md5($input) . $salt) == $hash;
    }

    public static function comparePhpass($hash, $input){
        $passwordHash = new PasswordHash(8, true);
        return $passwordHash->CheckPassword($input, $hash);
    }

    public static function generatePhpass($password){
        $passwordHash = new PasswordHash(8, true);
        return $passwordHash->HashPassword($password);
    }
}